import { Toast } from "antd-mobile";
import { testCenterService } from "@/store/actions/TestCenterService";
import { getApiParms } from "./configImpl";

/**
 * 应用配置数据
 */
export const APP_SHOW_DATA = {
    config: '',
    process: ''
};


/**
 * 获取应用配置数据
 */
export const getAppConfigCache = async () => {
    if (APP_SHOW_DATA.config.length === 0) {
        // 调用接口获取数据
        try {
            const parms = getApiParms("app_config");
            const { success, message, data } = await testCenterService.getResultList(parms);
            if (success) {
                APP_SHOW_DATA.config = data.data.config;
                APP_SHOW_DATA.process = data.data.process;

            } else {
                APP_SHOW_DATA.config = '';
                APP_SHOW_DATA.process = '';
                Toast.show(message);
            }
        } catch (error) {
            APP_SHOW_DATA.length = 0;
            console.error("获取应用配置数据出错:", error);
        }
    }
    return APP_SHOW_DATA;
};


